#include<stdio.h>
#include<stdlib.h>
typedef struct Node
{
    int data;
    struct Node *next;
}LNode;

int main()
{
    //freopen("in.txt","r",stdin);
    LNode *head = (LNode*)malloc(sizeof(LNode));
    LNode *rear = head;
    head->next = NULL;
    int n;
    while (scanf("%d",&n) != EOF)
    { 
        for(int i = 0;i < n; i++)
        {
            int x;
            scanf("%d",&x);
            LNode *pt = (LNode*)malloc(sizeof(LNode));
            pt->data = x;
            pt->next = NULL;
            rear->next = pt;
            rear = rear->next;
        }
        LNode  *head2 = head;
        int flag = 0;
        while (head2->next)
        {
            flag = 1;
            head2 = head2->next;
            printf("%d ",head2->data);
        }
        if(flag == 1) printf("\n");
        LNode *p = head->next;
        if(p==NULL) printf("list is empty");
        else
        {
            while (p->next != NULL)
            {
                LNode *pt = p->next;
                if(pt->data == p->data)
                {
                    p->next = pt->next;
                    free(pt);
                }
                else
                {
                    p = p->next;
                }
            }
        }   
        while (head->next)
        {
            head = head->next;
            printf("%d ",head->data);
        }
        printf("\n");
    }
}